﻿using AutoMapper;
using Common.Communal;
using MediatR;
using Sell.Api.Write.Application.Command.ContractCommand;
using Sell.Services.Contracts;

namespace Sell.Api.Write.Application.CommandHandlers.ContractCommandHandlers
{
    public class ContractDelCommandHandlers : IRequestHandler<ContractDelCommand, ApiResult<int>>
    {
        public IContractServices services { get; }
        public ContractDelCommandHandlers(IContractServices _services)
        { 
            services = _services;
        }
        /// <summary>
        /// 删除采购合同
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ApiResult<int>> Handle(ContractDelCommand request, CancellationToken cancellationToken)
        {
            return await services.DeleteContract(request.Id);
        }
    }
}
